package com.kuang.swagger.controller;

import com.kuang.swagger.pojo.User;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: swagger-demo
 * @description:
 * @author: 陈恩涛
 * @create: 2020-11-02 10:05
 **/

@Controller
public class HelloController {

    @GetMapping("/hello")
    @ResponseBody
    @ApiOperation("返回hello,Swagger")
    public String hello(){
        return "hello,Swagger!";
    }

    //只要我们的接口中，返回值中存在实体类，它就会被扫描到Swagger中
    @PostMapping
    public User user(){
        return new User();
    }

    @GetMapping("/hello2")
    @ResponseBody
    @ApiOperation("对登录的用户说hello")
    @ApiImplicitParam(paramType="query", name = "username", value = "用户名", required = true, dataType = "String")
    public String hello2(String username) {
        return  "hello"+username;
    }


    @PostMapping("/postt")
    @ResponseBody
    @ApiOperation("Post测试类")
    public User postt(User user){
        return user;
    }

}
